//
//  HomeBaseCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/20.
//

#import "HomeBaseCell.h"

@interface HomeBaseCell()
@property (nonatomic,strong) UIView * bgview;
@property (nonatomic,strong) UIImageView * ltopView;
@property (nonatomic,strong) UIImageView * rtopView;
@property (nonatomic,strong) UIImageView * lbotView;
@property (nonatomic,strong) UIImageView * rbotView;
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) UILabel * titleLabel;

@end

@implementation HomeBaseCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = UIColor.clearColor;
        self.contentView.backgroundColor = UIColor.clearColor;
        [self setSubViewLayout];
    }
    return self;
}
-(void)setSubViewLayout{
    
    [self addSubview:self.bgview];
    [_bgview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(@0);
        make.left.mas_offset(16 * FMScaleX);
        make.right.mas_offset(-16 * FMScaleX);
        make.top.mas_offset(10 * FMScaleX);
    }];
    
    [self.bgview addSubview:self.ltopView];
    [_ltopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(@0);
        make.size.mas_offset(CGSizeMake(24* FMScaleX ,24 * FMScaleX));
    }];
    [self.bgview addSubview:self.rtopView];
    [_rtopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.equalTo(@0);
        make.size.mas_offset(CGSizeMake(24* FMScaleX ,24 * FMScaleX));
    }];
    [self.bgview addSubview:self.lbotView];
    [_lbotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.equalTo(@0);
        make.size.mas_offset(CGSizeMake(24* FMScaleX ,24 * FMScaleX));
    }];
    [self.bgview addSubview:self.rbotView];
    [_rbotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.equalTo(@0);
        make.size.mas_offset(CGSizeMake(24* FMScaleX ,24 * FMScaleX));
    }];
    [self.bgview addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(200 * FMScaleX, 24 * FMScaleX));
        make.centerX.equalTo(@0);
        make.top.mas_offset(12 * FMScaleX);
    }];
    [self.bgview addSubview:self.titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.iconView);
    }];
}

-(UIView *)bgview{
    
    if (!_bgview) {
        _bgview = [[UIView alloc]init];
        _bgview.backgroundColor = RDRGB(0xFBF9F7);
        [_bgview setCornerRadius:4 * FMScaleX borderWidth:1 borderColor:RDRGB(0xDECFB9)];
    }
    return _bgview;
}

-(UIImageView *)ltopView{
    
    if (!_ltopView ) {
        _ltopView = [[UIImageView alloc]init];
        _ltopView.image = [UIImage imageNamed:@"Home_list_ltop"];
    }
    return _ltopView;
}
-(UIImageView *)rtopView{
    
    if (!_rtopView ) {
        _rtopView = [[UIImageView alloc]init];
        _rtopView.image = [UIImage imageNamed:@"Home_list_rtop"];
    }
    return _rtopView;
}
-(UIImageView *)lbotView{
    
    if (!_lbotView ) {
        _lbotView = [[UIImageView alloc]init];
        _lbotView.image = [UIImage imageNamed:@"Home_list_lbottom"];
    }
    return _lbotView;
}
-(UIImageView *)rbotView{
    
    if (!_rbotView ) {
        _rbotView = [[UIImageView alloc]init];
        _rbotView.image = [UIImage imageNamed:@"Home_list_rbottom"];
    }
    return _rbotView;
}
-(UIImageView *)iconView{
    
    if (!_iconView ) {
        _iconView = [[UIImageView alloc]init];
        _iconView.image = [UIImage imageNamed:@"Common_tips_icon"];
    }
    return _iconView;
}
-(UILabel *)titleLabel{
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = Bold(15);
        _titleLabel.textColor = RDRGB(0x9A7742);
        _titleLabel.text = @"睡眠压力";
    }
    return _titleLabel;
}
@end
